#include<vector>
#include<iostream>
#include<unordered_map>
using namespace std;

string find(const string& str, int k) {
    if (str.length() < k) return "";
    if (str.length() == k) return str;
    int num = 0;
    int res_left = 0, res_right = k;
    double maxRatio = -1;
    int left = 0, right = 0;
    while (right <= str.length()) {
        while (right++ < str.length()) {
            if (str[right-1] == 'G' || str[right-1] == 'C') {
                ++num;
                ++right;
            }
            else if (right - left < k) {
                continue;
            }
            else
                break;
        }
        double ratio = num * 1.0 / (right - left);
        if (ratio > maxRatio) {
            maxRatio = ratio;
            res_left = left;
            res_right = right;
        }
        bool flag = false;
        while (left++ < right) {
            if (str[left-1] == 'G' || str[left-1] == 'C') {
                --num;
                break;
            }
        }
    }
    return str.substr(res_left, res_right - res_left);
}

int main() {
    string str;
    int k;
    while (cin >> str >> k) {
        cout << find(str, k) << endl;
    }

}